package com.example.javatwo.controller.xs.lyh;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.javatwo.pojo.xs.lyh.allocate;
import com.example.javatwo.pojo.xs.lyh.pageBean;
import com.example.javatwo.service.xs.lyh.AllocateBizImpl;

@Controller
public class TextContrlyh {
	
	@Autowired
	private AllocateBizImpl allbiz;

	/**
	 * 页面跳转,不能在这里写代码
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/Allocate")
	public String Allocate() throws Exception{
		return "xs/lyh/Allocate";
	}
	
	
	/**
	 * 调拨单查询
	 * @param map
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/querylyh")
	@ResponseBody
	public pageBean query(@RequestParam Map<String, Object> map) throws Exception{
		pageBean pb = this.allbiz.queryAllocateInfo(map);
		return pb;
	}
	
	/**
	 * 新增
	 * @param allo
	 * @throws Exception
	 */
	@RequestMapping("/insertlyh")
	@ResponseBody
	public void insert(@RequestBody allocate allo) throws Exception{
		allbiz.insertAllocate(allo);
	}
	
	
	/**
	 * 修改
	 * @param allo
	 * @throws Exception
	 */
	@RequestMapping("/updateAllocate")
	@ResponseBody
	public void updateAllocate(@RequestBody allocate allo) throws Exception{
		allbiz.updateAllocate(allo);
	}
	
	/**
	 * 修改=》 调出仓库：仓库数量减少
	 * @param shuliang
	 * @param wareHouseID
	 * @throws Exception
	 */
	@RequestMapping("/updateDepotDetaillyh")
	@ResponseBody
	public void updateDepotDetaillyh(Integer shuliang,Integer wareHouseID) throws Exception{
		allbiz.updateDepotDetaillyh(shuliang, wareHouseID);
	}
	
	
	/**
	 * 修改=》调入仓库：仓库数量增加
	 * @param shuliang
	 * @param wareHouseID
	 * @throws Exception
	 */
	@RequestMapping("/updateDepotDetaillyh1")
	@ResponseBody
	public void updateDepotDetaillyh1(Integer shuliang,Integer wareHouseID) throws Exception{
		allbiz.updateDepotDetaillyh1(shuliang, wareHouseID);
	}
	
	/**
	 * 做出审核-反审核
	 * @param moveNom
	 * @param isShenHe
	 * @throws Exception
	 */
	@RequestMapping("/updateShenHeStuats")
	@ResponseBody
	public void updateShenHeStuats(String moveNo,String isShenHe) throws Exception{
//		System.out.println(isShenHe);
		allbiz.updateShenHeStuats(moveNo, isShenHe);
	}
	
	/**
	 * 单号
	 * @param moveNo
	 * @return
	 */
	@RequestMapping("/lyhdanhao")
	@ResponseBody
	public String danhao(String moveNo) throws Exception{
		String moveNos = moveNo.substring(0, 10);
		return this.allbiz.queryMaxlyh(moveNos);
	}
	
}
